package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.model.collectDeviceType.CollectDeviceTypeModel;
import com.hzhr.iot.device.entity.CollectDeviceTypeEntity;
import com.hzhr.iot.device.entity.ext.CollectDeviceTypeEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.collectDeviceType.CollectDeviceTypeModel;
import com.hzhr.iot.device.model.collectDeviceType.CollectDeviceTypeGetModel;
import com.hzhr.iot.device.model.collectDeviceType_des.CollectDeviceType_DesModel;
import com.hzhr.iot.device.model.collectDeviceType_des.CollectDeviceType_DesGetModel;
import com.hzhr.iot.device.queryModel.custom.CollectDeviceTypeCustomQueryModel;

@Component
public class CollectDeviceTypeConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    DeviceInfoCardCustomConvertor deviceInfoCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardCustomConvertor deviceMaintenanceCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplIotDeviceTypeCustomConvertor implIotDeviceTypeCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    IotDeviceTypeCustomConvertor iotDeviceTypeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    ProdFactoryCustomConvertor prodFactoryCustomConvertor;
    @Autowired
    RegulatorCollectDataCustomConvertor regulatorCollectDataCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public CollectDeviceTypeEntity collectDeviceTypeModel2entity(CollectDeviceTypeModel in) {
        //未转换字段: createUserId createTime updateUserId isValid outId updateTime state 
        if (in == null) return null;
        CollectDeviceTypeEntity result = new CollectDeviceTypeEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setProdFactoryId(HzhrTypeUtil.integer2integer(in.getProdFactoryId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public CollectDeviceTypeEntity collectDeviceTypeModel2entity(CollectDeviceTypeModel in, CollectDeviceTypeEntity ori) {
        //未转换字段: createUserId createTime updateUserId isValid outId updateTime state 
        if (in == null) return null;
        CollectDeviceTypeEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setProdFactoryId(HzhrTypeUtil.integer2integer(in.getProdFactoryId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public List<CollectDeviceTypeEntity> collectDeviceTypeModelList2entityList(List<CollectDeviceTypeModel> in) {
        if (in == null) return null;
        List<CollectDeviceTypeEntity> result = new ArrayList<>();
        for (CollectDeviceTypeModel item : in) {
            result.add(collectDeviceTypeModel2entity(item));
        }
        return result;
    }
    public CollectDeviceTypeModel entity2collectDeviceTypeModel(CollectDeviceTypeEntity in) {
        //未转换字段: 
        if (in == null) return null;
        CollectDeviceTypeModel result = new CollectDeviceTypeModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setProdFactoryId(HzhrTypeUtil.integer2integer(in.getProdFactoryId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public List<CollectDeviceTypeModel> entityList2collectDeviceTypeModelList(List<CollectDeviceTypeEntity> in) {
        if (in == null) return null;
        List<CollectDeviceTypeModel> result = new ArrayList<>();
        for (CollectDeviceTypeEntity item : in) {
            result.add(entity2collectDeviceTypeModel(item));
        }
        return result;
    }
    public CollectDeviceTypeModel ext2collectDeviceTypeModel(CollectDeviceTypeEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        CollectDeviceTypeModel result = new CollectDeviceTypeModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        result.setProdFactoryId(HzhrTypeUtil.integer2integer(in.getProdFactoryId()));
        result.setDeviceCategoryCode(HzhrTypeUtil.string2string(in.getDeviceCategoryCode()));
        return result;
    }
    public List<CollectDeviceTypeModel> extList2collectDeviceTypeModelList(List<CollectDeviceTypeEntityExt> in) {
        if (in == null) return null;
        List<CollectDeviceTypeModel> result = new ArrayList<>();
        for (CollectDeviceTypeEntityExt item : in) {
            result.add(ext2collectDeviceTypeModel(item));
        }
        return result;
    }
    public CollectDeviceTypeGetModel extList2collectDeviceTypeGetModel(List<CollectDeviceTypeEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<CollectDeviceTypeModel> modelList = extList2collectDeviceTypeModelList(extList);
        if (modelList == null) {
            CollectDeviceTypeGetModel result = new CollectDeviceTypeGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (CollectDeviceTypeModel model : modelList) {
                model.setDes(null);
                model.setCompanyId(null);
                model.setProdFactoryId(null);
                model.setDeviceCategoryCode(null);
            }
        }

        CollectDeviceTypeGetModel result = new CollectDeviceTypeGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public CollectDeviceTypeGetModel entity2collectDeviceTypeGetModel(CollectDeviceTypeEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<CollectDeviceTypeEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2collectDeviceTypeGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, CollectDeviceTypeEntityExt.class));
        return extList2collectDeviceTypeGetModel(extList, total, changeCount, query);
     }
    public CollectDeviceTypeEntity collectDeviceType_DesModel2entity(CollectDeviceType_DesModel in) {
        //未转换字段: companyId createUserId prodFactoryId createTime updateUserId isValid outId updateTime state deviceCategoryCode 
        if (in == null) return null;
        CollectDeviceTypeEntity result = new CollectDeviceTypeEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public CollectDeviceTypeEntity collectDeviceType_DesModel2entity(CollectDeviceType_DesModel in, CollectDeviceTypeEntity ori) {
        //未转换字段: companyId createUserId prodFactoryId createTime updateUserId isValid outId updateTime state deviceCategoryCode 
        if (in == null) return null;
        CollectDeviceTypeEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<CollectDeviceTypeEntity> collectDeviceType_DesModelList2entityList(List<CollectDeviceType_DesModel> in) {
        if (in == null) return null;
        List<CollectDeviceTypeEntity> result = new ArrayList<>();
        for (CollectDeviceType_DesModel item : in) {
            result.add(collectDeviceType_DesModel2entity(item));
        }
        return result;
    }
    public CollectDeviceType_DesModel entity2collectDeviceType_DesModel(CollectDeviceTypeEntity in) {
        //未转换字段: 
        if (in == null) return null;
        CollectDeviceType_DesModel result = new CollectDeviceType_DesModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<CollectDeviceType_DesModel> entityList2collectDeviceType_DesModelList(List<CollectDeviceTypeEntity> in) {
        if (in == null) return null;
        List<CollectDeviceType_DesModel> result = new ArrayList<>();
        for (CollectDeviceTypeEntity item : in) {
            result.add(entity2collectDeviceType_DesModel(item));
        }
        return result;
    }
    public CollectDeviceType_DesModel ext2collectDeviceType_DesModel(CollectDeviceTypeEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        CollectDeviceType_DesModel result = new CollectDeviceType_DesModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<CollectDeviceType_DesModel> extList2collectDeviceType_DesModelList(List<CollectDeviceTypeEntityExt> in) {
        if (in == null) return null;
        List<CollectDeviceType_DesModel> result = new ArrayList<>();
        for (CollectDeviceTypeEntityExt item : in) {
            result.add(ext2collectDeviceType_DesModel(item));
        }
        return result;
    }
    public CollectDeviceType_DesGetModel extList2collectDeviceType_DesGetModel(List<CollectDeviceTypeEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<CollectDeviceType_DesModel> modelList = extList2collectDeviceType_DesModelList(extList);
        if (modelList == null) {
            CollectDeviceType_DesGetModel result = new CollectDeviceType_DesGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (CollectDeviceType_DesModel model : modelList) {
                model.setDes(null);
            }
        }

        CollectDeviceType_DesGetModel result = new CollectDeviceType_DesGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public CollectDeviceType_DesGetModel entity2collectDeviceType_DesGetModel(CollectDeviceTypeEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<CollectDeviceTypeEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2collectDeviceType_DesGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, CollectDeviceTypeEntityExt.class));
        return extList2collectDeviceType_DesGetModel(extList, total, changeCount, query);
     }
    public CollectDeviceTypeCustomQueryModel collectDeviceTypeService_query2queryModel(Map<String, Object> query) {
        CollectDeviceTypeCustomQueryModel queryModel = new CollectDeviceTypeCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Integer _equal_companyId = HzhrTypeUtil.object2integer(query.get("_equal_companyId"));
        if (_equal_companyId != null) {
            queryModel.setEqual_companyId(_equal_companyId);
         }

        String _equal_deviceCategoryCode = HzhrTypeUtil.object2string(query.get("_equal_deviceCategoryCode"));
        if (_equal_deviceCategoryCode != null) {
            queryModel.setEqual_deviceCategoryCode(_equal_deviceCategoryCode);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }
    public CollectDeviceTypeCustomQueryModel collectDeviceType_DesService_query2queryModel(Map<String, Object> query) {
        CollectDeviceTypeCustomQueryModel queryModel = new CollectDeviceTypeCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Integer _equal_companyId = HzhrTypeUtil.object2integer(query.get("_equal_companyId"));
        if (_equal_companyId != null) {
            queryModel.setEqual_companyId(_equal_companyId);
         }

        String _equal_deviceCategoryCode = HzhrTypeUtil.object2string(query.get("_equal_deviceCategoryCode"));
        if (_equal_deviceCategoryCode != null) {
            queryModel.setEqual_deviceCategoryCode(_equal_deviceCategoryCode);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

